﻿
Imports System.Text

Namespace std
    Public Module operators
        Public Delegate Function ToStringMethod(Of T)(ByVal it As randomAccessIterator(Of T)) As String

        Public Function emptyToString(Of T)(ByVal it As randomAccessIterator(Of T)) As String
            Return Convert.ToString(+it)
        End Function

        Public Function ToString(Of itt, T As randomAccessIterator(Of itt)) _
                                (ByVal f As ToStringMethod(Of itt), _
                                 ByVal start As T, ByVal [end] As T, _
                                 Optional ByVal seperator As String = character.tab) As String
            assert(Not f Is Nothing, "f is not a valid ToStringMethod.")

            Dim rtn As StringBuilder = Nothing
            rtn = New StringBuilder()
            While start <> [end]
                rtn.Append(f(start))
                start += 1
                If start <> [end] Then
                    rtn.Append(seperator)
                End If
            End While
            Return Convert.ToString(rtn)
        End Function

        Public Delegate Sub insertDelegate(Of T, T2)(ByVal container As T, ByVal entity As T2)

        Public Sub vectorInsert(ByVal result As vector(Of String), ByVal entity As String)
            'do not use assert here
            result.push_back(entity)
        End Sub

        Public Sub setInsert(ByVal result As [set](Of String), ByVal entity As String)
            'do not use assert here
            result.insert(entity)
        End Sub

        Public Sub listInsert(ByVal result As list(Of String), ByVal entity As String)
            'do not use assert here
            result.push_back(entity)
        End Sub

    End Module
End Namespace
